package com.spider.moudle.util;

import com.spider.moudle.constant.Constant;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ErrorLogUtil {

    private static Log log = LogFactory.getLog("exception");

    public static void error(String msg,Exception e){
        String runMethod = PropertiesUtil.getVal("run.method");
        switch (runMethod) {
            case "DEVELOP": {
                e.printStackTrace();
                break;
            }
            case "OFFICIAL": {
                log.error(msg,e);
                break;
            }
            default: {
                break;
            }
        }

    }

    public static void error(String msg){
        String runMethod = PropertiesUtil.getVal("run.method");
        switch (runMethod) {
            case "DEVELOP": {
                System.err.println(msg);
                break;
            }
            case "OFFICIAL": {
                log.error(msg);
                break;
            }
            default: {
                break;
            }
        }

    }

    public static void error(Exception e){
        String runMethod = PropertiesUtil.getVal("run.method");
        switch (runMethod) {
            case "DEVELOP": {
                e.printStackTrace();
                break;
            }
            case "OFFICIAL": {
                log.error(e);
                break;
            }
            default: {
                break;
            }
        }

    }
}
